﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoftwareClass_1
{
    class DBhelper
    {
        private static readonly string consql = "server =PC-202001311751\\MYSQLSERVER ;uid =yun0823 ;pwd =jxy130452 ;database =Blogs ";
        public static DataTable GetDataTable(string sql)
        {
            SqlConnection sqlconn = new SqlConnection(consql);
            SqlDataAdapter sqlData = new SqlDataAdapter(sql,consql);
            DataTable dt = new DataTable();
            sqlData.Fill(dt);
            sqlconn.Open();
            return dt;
        }


        public static int AddOrDelete(string sql)
        {
            SqlConnection sqlconn = new SqlConnection(consql);
            SqlCommand sqlcomm = new SqlCommand(sql, sqlconn);
            sqlconn.Open();
            return sqlcomm.ExecuteNonQuery();

        }

    }
}
